package cn.tedu.tmall.admin.content.controller;

import cn.tedu.tmall.common.web.JsonResult;
import cn.tedu.tmall.admin.content.pojo.CategoryAddParam;
import cn.tedu.tmall.admin.content.service.ICategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/categories")
@Tag(name="类别接口")
@Validated
@Slf4j
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;
    /**
     *
     * @param categoryAddParam
     * @return
     */
    @Operation(summary = "增加类别")
    @PostMapping("/add")
    public JsonResult add(@Validated @RequestBody CategoryAddParam categoryAddParam) {
        log.debug("增加类别接口-入参:{}",categoryAddParam);
        System.out.println("categoryAddParam = " + categoryAddParam.getName());
        categoryService.add(categoryAddParam);
        JsonResult ok = JsonResult.ok();
        log.debug("增加类别接口-入参:{},出参:{}",categoryAddParam,ok);
        return ok;
    }
}
